package com.example.workflow.pojo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result<T> {

    private Integer code;

    private String message;

    private T data;

    public static<T> Result<T> success() {
        return new Result<>(SUCCESS_CODE,"操作成功",null);
    }
    public static<T> Result<T> success(T data) {
        return new Result<>(SUCCESS_CODE, "操作成功", data);
    }
    public static<T> Result<T> success(String message, T data) {
        return new Result<>(SUCCESS_CODE,message,data);
    }
    public static<T> Result<T> error() {
        return new Result<>(ERROR_CODE,"操作失败",null);
    }
    public static<T> Result<T> error(T data) {
        return new Result<>(ERROR_CODE,"操作失败",data);
    }
    public static<T> Result<T> error(String message) {
        return new Result<>(ERROR_CODE,message,null);
    }
    public static<T> Result<T> error(String message, T data) {
        return new Result<>(ERROR_CODE,message,data);
    }
    public static<T> Result<T> error(int code, String message) {
        return new Result<>(code,message,null);
    }

    public static Integer SUCCESS_CODE = 200; // 操作成功
    public static Integer ERROR_CODE = 500; // 操作失败
    public static Integer NOT_FOUND_CODE = 404;
    public static Integer NOT_LOGIN_CODE = 401;
    public static Integer LOGIN_ERROR_CODE = 405;   // 登录失败
    public static Integer LOGOUT_ERROR_CODE = 406;  // 登出失败
}
